class userViolation():
    name = "周奕涵"
    sex ='男'
    debt =0
    book_name="雪国"
    author="川端康成"
    borrow_time=2023-5-1
    return_time=2023-5-2
    due_time=2023-5-1
    valid_time=2023-6-1
    def __init__(self, name,sex,bookname,author,borrowtime,returntime,duetime,debt,validtime):
        self.name = name
        self.sex = sex
        self.book_name = bookname
        self.author = author
        self.borrow_time = borrowtime
        self.return_time = returntime
        self.due_time = duetime
        self.debt = debt
        self.valid_time=validtime


import random
import uuid
from aliyunsdkcore.request import RpcRequest
import config
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.profile import region_provider

acs_client = AcsClient(config.ACCESS_KEY_ID, config.ACCESS_KEY_SECRET, config.REGION)
region_provider.add_endpoint(config.PRODUCT_NAME, config.REGION, config.DOMAIN)


class RandomNumber(object):
    # 生成数字
    @classmethod
    def rand_num(cls):
        return str(random.randint(0, 9))

    # 生成大写字母
    @classmethod
    def rand_upper(cls):
        return chr(random.randint(65, 90))

    # 生成小写字母
    @classmethod
    def rand_lower(cls):
        return chr(random.randint(97, 122))

    # 生成n位随机验证码
    @classmethod
    def rand_value(cls, ty=0, n=4):
        lst = ["rand_num", "rand_upper", "rand_lower"]
        str = ""
        for i in range(n):
            str += (eval("cls." + lst[ty])())
        return str


class SendSmsRequest(RpcRequest):
    def __init__(self):
        RpcRequest.__init__(self, 'Dysmsapi', '2017-05-25', 'SendSms')

    def get_TemplateCode(self):
        return self.get_query_params().get('TemplateCode')

    def set_TemplateCode(self, TemplateCode):
        self.add_query_param('TemplateCode', TemplateCode)

    def get_PhoneNumbers(self):
        return self.get_query_params().get('PhoneNumbers')

    def set_PhoneNumbers(self, PhoneNumbers):
        self.add_query_param('PhoneNumbers', PhoneNumbers)

    def get_SignName(self):
        return self.get_query_params().get('SignName')

    def set_SignName(self, SignName):
        self.add_query_param('SignName', SignName)

    def get_ResourceOwnerAccount(self):
        return self.get_query_params().get('ResourceOwnerAccount')

    def set_ResourceOwnerAccount(self, ResourceOwnerAccount):
        self.add_query_param('ResourceOwnerAccount', ResourceOwnerAccount)

    def get_TemplateParam(self):
        return self.get_query_params().get('TemplateParam')

    def set_TemplateParam(self, TemplateParam):
        self.add_query_param('TemplateParam', TemplateParam)

    def get_ResourceOwnerId(self):
        return self.get_query_params().get('ResourceOwnerId')

    def set_ResourceOwnerId(self, ResourceOwnerId):
        self.add_query_param('ResourceOwnerId', ResourceOwnerId)

    def get_OwnerId(self):
        return self.get_query_params().get('OwnerId')

    def set_OwnerId(self, OwnerId):
        self.add_query_param('OwnerId', OwnerId)

    def get_SmsUpExtendCode(self):
        return self.get_query_params().get('SmsUpExtendCode')

    def set_SmsUpExtendCode(self, SmsUpExtendCode):
        self.add_query_param('SmsUpExtendCode', SmsUpExtendCode)

    def get_OutId(self):
        return self.get_query_params().get('OutId')

    def set_OutId(self, OutId):
        self.add_query_param('OutId', OutId)


def send_sms(phone_numbers, template_param=None):
    business_id = uuid.uuid4()
    sms_request = SendSmsRequest()
    sms_request.set_TemplateCode(config.template_code)  # 短信模板变量参数
    if template_param is not None:
        sms_request.set_TemplateParam(template_param)
    sms_request.set_OutId(business_id)  # 设置业务请求流水号，必填。
    sms_request.set_SignName(config.sign_name)  # 短信签名
    sms_request.set_PhoneNumbers(phone_numbers)  # 短信发送的号码列表，必填。
    sms_response = acs_client.do_action_with_exception(sms_request)  # 调用短信发送接口，返回json
    return sms_response
